/**
 * Copyright (C) 2011-2012 Luca Li Greci
 *
 * This file is part of pojo-creator
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.pojocreator.fluent;

import com.pojocreator.model.real.Car;

/**
 * This is an example to show a traditional Car builder using 
 * fluent API
 * 
 * @author Luca Li Greci
 *
 */
public final class CarBuilder {
    private Car car;
    
    /**
     * Private constructor to hide the instance 
     * creation.
     */
    private CarBuilder() {
        car = new Car();
    }
    
    /**
     * @return a new instance of CarBuilder
     */
    public static CarBuilder builder(){
        return new CarBuilder();
    }
    
    /**
     * Set the car owner
     * 
     * @param owner Owner 
     * @return this builder to carry on with the building
     */
    public  CarBuilder owner(String owner) {
        car.setOwner(owner);
        return this;
    }
    
    /**
     * Set the car brand
     * 
     * @param brand Brand
     * @return this builder to carry on with the building
     */
    public CarBuilder brand(String brand) {
        car.setBrand(brand);
        return this;
    }
    
    public Car build() {
        return car;
    }
}
